
package com.jf.cloud.api.order.feign;

import com.jf.cloud.api.order.bo.EsOrderRefundBO;
import com.jf.cloud.api.order.vo.*;
import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

/**
 * @author zz
 * @date 2020/11/23
 */
@FeignClient(value = "jfcloud-order",contextId = "order-refund")
public interface OrderRefundFeignClient {


    /**
     * 获取退款状态
     * @param refundId 退款id
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/refund/getRefundStatus")
    ServerResponseEntity<Integer> getRefundStatus(@RequestParam("refundId") Long refundId);

    /**
     * 根据参数获取商品退款订单数据分析
     * @param spuIds 商品id列表
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return 商品退款订单数据
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/refund/getProdRefundEffectByDateAndProdIds")
    ServerResponseEntity<List<OrderRefundProdEffectRespVO>> getProdRefundEffectByDateAndProdIds(@RequestParam("spuIds")List<Long> spuIds,
                                                                                                @RequestParam("startTime")Long startTime,
                                                                                                @RequestParam("endTime")Long endTime);
    /**
     * 通过订单id获取成功的退款订单
     * @param orderId 订单id
     * @param returnMoneySts 退款状态
     * @return 成功的退款订单
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/refund/getOrderRefundByOrderIdAndRefundStatus")
    ServerResponseEntity<List<OrderRefundVO>> getOrderRefundByOrderIdAndRefundStatus(@RequestParam("orderId")Long orderId, @RequestParam("returnMoneySts")Integer returnMoneySts);

    /**
     * 根据支付单号列表获取订单号列表
     * @param refundIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/settlement/listOrderIdsByRefundIds")
    ServerResponseEntity<List<OrderRefundSimpleVO>> listOrderIdsByRefundIds(@RequestBody List<Long> refundIds);

    /**
     * 通过退款编号id获取退款订单
     * @param refundId 退款id
     * @return 成功的退款订单
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/refund/getOrderRefundByRefundId")
    ServerResponseEntity<OrderRefundVO> getOrderRefundByRefundId(@RequestParam("refundId")Long refundId);

    /**
     * 获取mongodb中存储的指定退款信息
     * @param refundId 退款id
     * @return 成功的退款订单
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/refund/saveMongoAndGetEsOrderRefundInfo")
    ServerResponseEntity<EsOrderRefundBO> saveMongoAndGetEsOrderRefundInfo(@RequestParam("refundId") Long refundId);

    /**
     * 查询财务对账信息，使用mongodb，当有店铺名称查询需要时
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param shopName 店铺名称
     * @param shopId
     * @return 财务对账信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/insider/refund/getAccountOrderDetail")
    ServerResponseEntity<AccountOrderDetailVO> getAccountOrderDetail(@RequestParam(value = "startTime", required = false) Date startTime,
                                                                     @RequestParam(value = "endTime", required = false) Date endTime,
                                                                     @RequestParam(value = "shopName", required = false) String shopName,
                                                                     @RequestParam(value = "shopId",required = false) Long shopId);

    /**
     * 查询财务对账信息，使用mongodb，当有店铺名称查询需要时
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param shopName 店铺名称
     * @param pageNum
     * @param pageSize
     * @return 财务对账信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/insider/refund/listShopAccountDetail")
    ServerResponseEntity<PageShopAccountOrderVO> listShopAccountDetail(@RequestParam(value = "startTime", required = false) Date startTime,
                                                                       @RequestParam(value = "endTime",required = false) Date endTime,
                                                                       @RequestParam(value = "shopName",required = false) String shopName,
                                                                       @RequestParam("pageSize") Integer pageSize,
                                                                       @RequestParam("pageNum") Integer pageNum);

    /**
     * 查询财务对账信息，使用mongodb，当有店铺名称查询需要时
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param shopId 店铺id
     * @param shopName
     * @param pageNum
     * @param pageSize
     * @return 财务对账信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/insider/refund/listOrderRefundInfo")
    ServerResponseEntity<PageShopAccountOrderVO> listOrderRefundInfo(@RequestParam(value = "startTime", required = false) Date startTime,
                                                                     @RequestParam(value = "endTime",required = false) Date endTime,
                                                                     @RequestParam(value = "shopId",required = false) Long shopId,
                                                                     @RequestParam(value = "shopName",required = false) String shopName,
                                                                  @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                                  @RequestParam(value = "pageNum", required = false) Integer pageNum);

    /**
     * 执行退款请求
     *
     * @param extendInfo
     */
    @PostMapping(FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/insider/refund/doRefund")
    void doRefund(@RequestBody String extendInfo);
}
